//
//  ChatViewController.h
//  Gabber
//
//  Created by 陆惠国 on 11-8-26.
//  Copyright 2011年 恒生聚源. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "HPGrowingTextView.h"

@class Message;
@class RosterTitleView;

@interface ChatViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextViewDelegate,NSFetchedResultsControllerDelegate, HPGrowingTextViewDelegate>
{
    NSFetchedResultsController* _fetchedResultsController;
    NSMutableArray* _items;
    NSString* _jidStr;
    RosterTitleView* _titleView;
    UIView *_contentView;
    UITableView *_chatContent;
    UIView *_chatHeaderView;
    UIView *_chatBar;
    HPGrowingTextView * _chatInput;
    UIButton *_sendButton;
    UIImage *_leftBubble;
    UIImage *_rightBubble;
    UIImage *_myAvatar;
    UIImage *_avatar;
    NSDate* _lastDate;
    BOOL _showHistory;
    BOOL _active;
    
    UIButton *_loadHistoryButton;
    UIButton *_clearHistoryButton;
    //UIToolbar *_toolbar;
    
    
    UIButton *_facialButton;
    UIScrollView* _scrollView; 
    NSMutableArray *_sendfaceArray;
    NSMutableArray *_receivefaceArray;
    UIPopoverController* _facialPopover;
    
}

@property (nonatomic, readonly) NSFetchedResultsController* fetchedResultsController;
@property (nonatomic, retain) NSMutableArray* items;
@property (nonatomic, copy) NSString* jidStr;

@property (nonatomic, retain) RosterTitleView* titleView;
@property (nonatomic, retain) UIView *contentView;
@property (nonatomic, retain) UITableView *chatContent;
@property (nonatomic, retain) UIView *chatHeaderView;
@property (nonatomic, retain) UIView *chatBar;
@property (nonatomic, retain) HPGrowingTextView *chatInput;
@property (nonatomic, retain) UIButton *sendButton;
@property (nonatomic, retain) UIButton *loadHistoryButton;
@property (nonatomic, retain) UIButton *clearHistoryButton;

@property (nonatomic, retain) UIImage *leftBubble;
@property (nonatomic, retain) UIImage *rightBubble;
@property (nonatomic, retain) UIImage *myAvatar;
@property (nonatomic, retain) UIImage *avatar;

@property (nonatomic, assign) BOOL showHistory;
@property (nonatomic, assign) BOOL active;
@property (nonatomic, retain) NSDate *lastDate;


@property (nonatomic, retain) UIButton *facialButton;
@property (nonatomic, retain) UIScrollView* scrollView;
@property (nonatomic, retain) NSMutableArray* sendfaceArray;
@property (nonatomic, retain) NSMutableArray* receivefaceArray;
@property (nonatomic, retain) UIPopoverController* facialPopover;

- (id)initWithJidStr:(NSString*)jidStr;

- (NSUInteger)addMessage:(Message *)message;
- (NSUInteger)removeMessageAtIndex:(NSUInteger)index;
//- (void)clearAll;

- (void)fetchMessages;
- (void)loadMessages;
- (void)reloadData;
- (void)reloadAvatar;

- (void)enableSendButton;
- (void)disableSendButton;
- (void)resetSendButton;

- (void)sendMessage;
- (void)clearChatInput;

- (void)scrollToBottomAnimated:(BOOL)animated;
- (void)loadHistoryAction;
- (void)clearHistoryAction;
@end
